package org.jeecg.chase.modules.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.ibatis.annotations.Param;
import org.jeecg.chase.modules.entity.AdhShopCategory;
import org.jeecg.chase.modules.mapper.AdhShopCategoryMapper;
import org.jeecg.chase.modules.service.IAdhShopCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;
import java.util.List;
import java.util.Map;

/**
 * @author leikai
 * @version 1.0
 * @description:
 * @date 2022/01/08/0008 15:33
 */
@SuppressWarnings("ALL")
@Service
@Transactional
public class AdhShopCategoryServiceImpl extends ServiceImpl<AdhShopCategoryMapper, AdhShopCategory> implements IAdhShopCategoryService {

    @Autowired
    private AdhShopCategoryMapper adhShopCategoryMapper;

    @Override
    public void deleteById(String id) {
        this.adhShopCategoryMapper.deleteById(id);
        this.adhShopCategoryMapper.deleteByParentId(id);
    }

    @Override
    public boolean updateStatus(String id, Integer status) {
        try {
            this.adhShopCategoryMapper.updateStatus(id, status);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }

    @Override
    public List<Map<String, Object>> queryParentData() {
        return this.adhShopCategoryMapper.queryParentData();
    }
    @Override
    public List<Map<String, Object>> querySubCategoryData( String categoryId){
        return this.adhShopCategoryMapper.querySubCategoryData(categoryId);
    }
    @Override
    public List<AdhShopCategory> queryCategoryForWeChatIndex(){
        return  this.adhShopCategoryMapper.queryCategoryForWeChatIndex();
    }
    @Override
    public List<AdhShopCategory> querySubCategory(String categoryId){
        return this.adhShopCategoryMapper.querySubCategory(categoryId);
    }
    @Override
    public List<Map<String,Object>> queryMerchCoupponByCategory(String categoryId){
        return  this.adhShopCategoryMapper.queryMerchCoupponByCategory(categoryId);

    }

    @Override
    public List<Map<String,Object>> queryMerchCoupponByCategoryAndCity( String categoryId,  String city){
        return  this.adhShopCategoryMapper.queryMerchCoupponByCategoryAndCity(categoryId,city);
    }
    @Override
    public List<Map<String,Object>> queryMerchByCategoryAndCity(  String categoryId,  String city){
        return  this.adhShopCategoryMapper.queryMerchByCategoryAndCity(categoryId,city);
    }
    @Override
    public List<Map<String,Object>> searchCoupon( String searchKey){
        return this.adhShopCategoryMapper.searchCoupon(searchKey);
    }
}
